package br.com.threads;
public class Smiley extends Thread {
	
	static String teste="teste";
	
	public Smiley(String name) {
		super(name);
	}

	public void run() { // (1)
		int i=0;
		while (i<10) { // (2)
				
			try { // (3)
				synchronized(Smiley.class){
					System.out.print(":"); // (4)
					sleep(100); // (5)
					System.out.print("-"); // (6)
					sleep(100); // (7)
					System.out.print(")"); // (8)
					sleep(100); // (9)
					System.out.println(" "+this.getName());
					//Smiley.class.notify();
				}
				
			} catch (Exception e) {
				//e.printStackTrace();
			}
			i++;
			
		}
		
	}

	public static void main(String[] args) {
			
			Smiley s = new Smiley("teste");
			s.exec();	
		
		
	}
	
	public synchronized void exec(){
		synchronized(teste){
			
			Thread t1 = new Smiley("t1");
			Thread t2 = new Smiley("t2");


			t1.start();
			t2.start();

		//	try {
	///			teste.wait();
	//			t2.join();
//				Thread.sleep(3000);
		//		t1.join();

		
			System.out.println("Acabou");
		}
	}
	
}